1. Field of the Invention
The present invention relates to a source code transformation process for transforming source code including a description concerning an object interaction method known as a stub method into source code which is adapted to a program execution environment. The present invention also is concerned with a computer-readable recording medium which stores a source code transformation program for implementing the source code transformation process. Details of certain features of the present invention are described in European Patent Application No. 0.753,811 A1 entitled xe2x80x9cData processing method and devicexe2x80x9d and filed by the same assignee on Jul. 12, 1996 claiming a Convention Priority on JP 178625/95, filed Jul. 14, 1997, the complete disclosure of which is hereby incorporated herein by reference.
2. Description of the Related Art
In general, object-oriented programming frequently uses object interaction methods. The term xe2x80x9cobject interactionxe2x80x9d is used in this specification to mean, for example, a process for sending a message from one object to another. The object interaction is an essential service offered by an operating system in object-oriented programming.
Methods employed in object interaction are generally referred to as xe2x80x9cstub methodsxe2x80x9d. Thus, a stub method is used in object-oriented programming for the purpose of sending a message from one object to another. In the following description, the object from which the message is sent will be referred to as a xe2x80x9cclient objectxe2x80x9d, while the object which receives the message will be referred to as a xe2x80x9cserver objectxe2x80x9d.
For instance, when it is desired to execute the procedure of a server object on another computer linked through a network, a message is sent through the network from the client object to the server object to be executed on the other computer. It is thus possible to execute the procedure of the server object on the other computer linked through the network. It will be understood that a remote control operation for calling a procedure to be executed on a different computer through a network can be performed in the same way as that performed by a local procedure call interface.
In general, a stub generator is used for generating a stub method. More specifically, such a stub generator reads source code containing information concerning a stub method described in a certain programming language and generates a stub method from the read source code. In most cases, the stub generator has both a function for generating a stub method concerning the client object which is the message sender and a function for generating a stub method concerning the server object which is the message receiver. With these functions, the client object and the server object can be set up very easily with a high degree of versatility.
A description will be given of a process for forming a program by using a stub generator.
Formation of the program using a stub generator includes describing a program for a non-object-interaction portion by means of the C++ programming language and describing a program for an object-interaction portion by using an interface definition language. The xe2x80x9cinterface definition languagexe2x80x9d is a language which defines the interface for the communication between the objects. The interface definition language may be, for example, a language determined by the CORBA (Common Object Request Broker Architecture) which is a rule for implementing object-oriented distributed processing environments.
More specifically, referring to FIG. 4, the process of forming an application program for object interaction begins with the formation of three kinds of source codes which are referred to as the xe2x80x9cfirst, xe2x80x9csecondxe2x80x9d and xe2x80x9cthirdxe2x80x9d source codes.
The first source code contains stub method information described in the interface definition language. This means that the interface to be used for the object interaction is defined by the first source code. In FIG. 4, a file f1 in which the first source code is written is indicated as xe2x80x9cTest.idlxe2x80x9d.
The second source code contains server object information described in a programming language such as C++. Thus, the second source code contains the portion of the server object information other than the object interaction information described in the first source code. The second source code further contains, for example, a procedure for calling, from the stub method described by the first source code, a method for generating a thread which performs processing based on the received message. In FIG. 4, a file f2 describing the second source code is represented by xe2x80x9cTest svc_proc.ccxe2x80x9d.
The third source code contains the client object information described in a programming language such as C++. It is to be noted that the third source code includes the portion of the client object information other than the object interaction information described in the first source code. Thus, the third code contains a description for implementing a main function, e.g., connection to an appropriate service, in the form of an application program. In FIG. 4, a file f3 in which the third code is described is represented by xe2x80x9cTest.ccxe2x80x9d and xe2x80x9cTest.hxe2x80x9d. The xe2x80x9cTest.hxe2x80x9d file is an include file which is incorporated in the xe2x80x9cTest.ccxe2x80x9d file.
The first source code described in the interface definition language is transformed by a stub generator 101 into source code described with the same programming language as that used for the description of the second and third source codes. Thus, the stub generator 101 generates a stub method which is described by a programming language such as C++ rather than by the interface definition language.
More specifically, the transformation performed by the stub generator 101 generates from the file f1 in which the first code is described, a file f4 which contains a stub method description for the server object, a file f5 containing a stub method description for the client object, and an include file f6 which is to be commonly used by objects involved in the object interaction.
In FIG. 4, the file f4 containing the stub method description for the server object is represented by xe2x80x9cTestStub.ccxe2x80x9d and xe2x80x9cTestStub.hxe2x80x9d. The xe2x80x9cTestStub.hxe2x80x9d file is an include file incorporated in the xe2x80x9cTestStub.ccxe2x80x9d file. The file f5 containing stub method description for the client object is represented by xe2x80x9cTestProxy.ccxe2x80x9d and xe2x80x9cTestProxy.hxe2x80x9d. The xe2x80x9cTestProxy.hxe2x80x9d file is an include file incorporated in the xe2x80x9cTestProxy.ccxe2x80x9d file. The include file f6 commonly used by the objects involved in the object interaction is represented by xe2x80x9cTestEntry.hxe2x80x9d and xe2x80x9cTestMsg.hxe2x80x9d.
Then, compilation is performed on each of the file f2 containing the description of the second source code, the file f3 containing the description of the third source code, and the files f4 to f6 generated by the stub generator 101, and the results of the compilation are linked, thereby forming a server object executable file f7 for the server object and a client object executable file f8
Thus, in the process shown in FIG. 4, the server object executable file f7 is generated by an executable file generating program 102 having a compiler and a linker from the resources which include the file f2 (Test_svc_proc.cc) describing the second source code, the file f4 (TestStub.cc, TestStub.h) containing the stub method description for the server object, and the include file f6 (TestEntry.h, TestMsg.h). which is commonly used by the objects taking part in the object interaction. At the same time, the client object executable file f8 is generated by an executable file generating program 103 having a compiler and a linker from the resources which include the file f3 (Test.h, Test.cc) describing the third source code, the file f5 (TestProxy.cc, TestProxy.h) containing the stub method description for the client object, and the include file f6 (TestEntry.h, TestMsg.h). which is commonly used by the objects taking part in the object interaction.
In general, there are a variety of environments under which programs are executed. Any application program, therefore, has to be formed so as to be suited to the program execution environment. This naturally requires that the program execution environment is suited also to the stub method which is generated in accordance with the nature of the application program and the demand. The stub generator, therefore, has to generate the stub method such that the stub method is suited to the execution environment of the application program that relies upon the generated stub method.
Therefore, it has been a conventional practice to prepare different stub generators which generate stub methods for different program execution environments. Thus, generation of a specific stub method requires selective use of the stub generator in accordance with the environment in which the application program which uses the stub method is to be executed.
Thus, the conventional technique for generating a stub method employs an operation performed by a stub generator for transforming source code described in an interface definition language. The following problems are encountered by this known technique.
Firstly, studying and learning interface definition languages are essential in order for the programmer to form an application program which uses a stub method, because the formation of source code described in a certain interface definition language is necessary. In general, interface definition languages and programming languages such as C++ have fundamentally different formats. Thus, an ordinary programmer, even if familiar with programming languages, has to spend much time studying and learning interface definition languages to such a degree as to become able to form a source code with an interface definition language. Consequently, much time and labor are necessary for forming an application program which uses a stub method.
A second problem pertains to the difficulty that lies in ascertaining matching between the interface constituted by the source code portion described in the interface definition language and the interface corresponding to the source code portion described in a programming language such as C++. This difficulty will be described in detail. A single application program formed by the procedure shown in FIG. 4 contains both a portion described in the interface definition language and a portion described in the programming language such as C++. As stated before, these two types of languages employ entirely different formats. Therefore, co-existence of a description in the interface definition language and a description in the programming language such as C++ makes it extremely difficult to confirm whether or not the interfaces of these descriptions match with each other.
A third problem is that the conventional stub generator cannot be used commonly for a plurality of different program execution environments. Therefore, as stated before, is has been necessary to prepare a plurality of stub generators which generate different stub methods suited to different program execution environments.
Fourthly, it is to be pointed out that only methods which have been determined by the interface definition languages are usable as the stub method. Thus, the users are not allowed to interactively change the contents of the stub method. In other words, the stub methods are determined in the procedure for designing the stub generators and, hence, are dependent on the stub generators. The contents of the stub methods therefore cannot be altered by users.
Accordingly, it is an object of the present invention to provide a source code transformation process which can easily be adapted to a variety of program execution environments and which can generate stub methods without using any interface definition language.
Another object of the present invention is to provide a computer-readable recording medium storing a source transformation program which implements the above-described source code transformation process.
To these ends, according to one aspect of the present invention, there is provided a source code transformation process, comprising the steps of: preparing a primary source code described with a predetermined programming language and containing information concerning a method to be used in an object interaction, the information being described in a format which is common to a plurality of different program execution environments; and transforming, by making a reference to registered information corresponding to the program execution environment on which the method is to be executed, the primary source code into a secondary source code described with the same programming language as the primary source code in a predetermined format corresponding to the program execution environment on which the method is to be executed.
According to another aspect of the present invention, there is provided a computer-readable recording medium, storing a source code transformation program that implements a process comprising the steps of: preparing a primary source code described with a predetermined programming language and containing information concerning a method to be used in an object interaction, the information being described in a format which is common to a plurality of different program execution environments; and transforming, by making a reference to registered information corresponding to the program execution environment on which the method is to be executed, the primary source code into a secondary source code described with the same programming language as the primary source code in a predetermined format corresponding to the program execution environment on which the method is to be executed.
These and other objects, features and advantages of the present invention will become clear from the following description of the preferred embodiment taken with reference to the accompanying drawings.